package com.dhcc.bpm.modules.cost.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.common.annotation.Log;
import com.dhcc.bpm.common.enums.BusinessType;
import com.dhcc.bpm.modules.cost.entity.RechargeInfo;
import com.dhcc.bpm.modules.cost.service.IRechargeInfoService;
import com.dhcc.bpm.modules.cost.vo.RechargeInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * @ClassName RechargeInfoController.class
 * @Description  充值记录表 控制器
 * @Author xiaFaYu
 * @Date 2019-12-16 14:16
 * @Version V1.0
 * @Copyright: 2020 东华软件 . All rights reserved.
 */
@RestController
@AllArgsConstructor
@RequestMapping("bpm-cost/rechargeInfo")
@Api(value = "充值记录表", tags = "充值记录表接口")
public class RechargeInfoController extends BladeController {
	private  final static Logger log = LoggerFactory.getLogger(RechargeInfoController.class);
	private IRechargeInfoService rechargeInfoService;

	/**
	 * @Description 详情
	 * @Author xiafayu
	 * @Date 2020/2/24 15:03
	 * @param rechargeInfo
	 * @return org.springblade.core.tool.api.R<com.dhcc.bpm.modules.cost.entity.RechargeInfo>
	 **/
	@ApiLog("充值记录详情")
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入rechargeInfo")
	@Log(title = "查询充值记录", businessType = BusinessType.SELECT)
	public R<RechargeInfo> detail(RechargeInfo rechargeInfo) {
		RechargeInfo detail = rechargeInfoService.getOne(Condition.getQueryWrapper(rechargeInfo));
		return R.data(detail);
	}

	/**
	 * @Description 分页 充值记录表
	 * @Author xiafayu
	 * @Date 2020/2/24 15:04
	 * @param rechargeInfo
	 * @param query
	 * @return org.springblade.core.tool.api.R<com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.cost.entity.RechargeInfo>>
	 **/
	@ApiLog("充值记录分页")
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入rechargeInfo")
	public R<IPage<RechargeInfo>> list(RechargeInfo rechargeInfo, Query query) {
		IPage<RechargeInfo> pages = rechargeInfoService.page(Condition.getPage(query), Condition.getQueryWrapper(rechargeInfo));
		return R.data(pages);
	}

	/**
	 * @Description 分页 充值记录表
	 * @Author xiafayu
	 * @Date 2020/2/24 15:04
	 * @param rechargeInfo
	 * @param query
	 * @return org.springblade.core.tool.api.R<com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.cost.entity.RechargeInfo>>
	 **/
	@ApiLog("充值记录分页")
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入rechargeInfo")
	@Log(title = "查询充值记录", businessType = BusinessType.SELECT)
	public R<IPage<RechargeInfoVO>> page(RechargeInfoVO rechargeInfo, Query query) {
		IPage<RechargeInfoVO> pages = rechargeInfoService.selectRechargeInfoPage(Condition.getPage(query), rechargeInfo);
		return R.data(pages);
	}

	/**
	 * @Description 新增 充值记录表
	 * @Author xiafayu
	 * @Date 2020/2/24 15:04
	 * @param rechargeInfo
	 * @return org.springblade.core.tool.api.R
	 **/
	@ApiLog("充值记录新增")
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入rechargeInfo")
	@Log(title = "新增充值记录", businessType = BusinessType.INSERT)
	public R save(@Valid @RequestBody RechargeInfo rechargeInfo) {
		return R.status(rechargeInfoService.save(rechargeInfo));
	}

	/**
	 * @Description 修改 充值记录表
	 * @Author xiafayu
	 * @Date 2020/2/24 15:04
	 * @param rechargeInfo
	 * @return org.springblade.core.tool.api.R
	 **/
	@ApiLog("充值记录修改")
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入rechargeInfo")
	@Log(title = "修改充值记录", businessType = BusinessType.UPDATE)
	public R update(@Valid @RequestBody RechargeInfo rechargeInfo) {
		return R.status(rechargeInfoService.updateById(rechargeInfo));
	}

	/**
	 * @Description 新增或修改 充值记录表
	 * @Author xiafayu
	 * @Date 2020/2/24 15:05
	 * @param rechargeInfo
	 * @return org.springblade.core.tool.api.R
	 **/
	@ApiLog("充值记录新增或修改")
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes = "传入rechargeInfo")
	@Log(title = "修改充值记录", businessType = BusinessType.UPDATE)
	public R submit(@Valid @RequestBody RechargeInfo rechargeInfo) {
		return R.status(rechargeInfoService.saveOrUpdate(rechargeInfo));
	}

	
	/**
	 * @Description 删除 充值记录表
	 * @Author xiafayu
	 * @Date 2020/2/24 15:05
	 * @param ids
	 * @return org.springblade.core.tool.api.R
	 **/
	@ApiLog("删除充值记录")
	@PostMapping("/remove")
	@ApiOperationSupport(order = 8)
	@ApiOperation(value = "删除", notes = "传入ids")
	@Log(title = "删除充值记录", businessType = BusinessType.DELETE)
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(rechargeInfoService.removeByIds(Func.toLongList(ids)));
	}

	
}
